package com.neusoft.yiyang.medical.controller;

import com.neusoft.yiyang.common.entity.medical.CheckOrderRecord;
import com.neusoft.yiyang.medical.service.CheckOrderRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "检查医嘱执行记录接口", description = "管理检查医嘱的执行情况记录，包括创建、查询、更新和删除")
@RestController
@RequestMapping("/check-order-record")
public class CheckOrderRecordController {

    @Autowired
    private CheckOrderRecordService checkOrderRecordService;

    @Operation(summary = "创建检查医嘱执行记录", description = "记录检查医嘱的执行情况（含执行时间、结果、执行人等）")
    @PostMapping("/create")
    public void createCheckOrderRecord(
            @Parameter(description = "检查医嘱执行记录信息（含检查医嘱ID、执行详情等）", required = true)
            @RequestBody CheckOrderRecord checkOrderRecord) {
        checkOrderRecordService.createCheckOrderRecord(checkOrderRecord);
    }

    @Operation(summary = "获取所有检查医嘱执行记录", description = "查询系统中所有检查医嘱的执行记录")
    @GetMapping("/all")
    public List<CheckOrderRecord> getAllCheckOrderRecords() {
        return checkOrderRecordService.getAllCheckOrderRecords();
    }

    @Operation(summary = "查询客户的检查医嘱执行记录", description = "获取指定客户的所有检查医嘱执行记录")
    @GetMapping("/customer/{customerId}")
    public List<CheckOrderRecord> getCheckOrderRecordsByCustomerId(
            @Parameter(description = "客户ID", required = true)
            @PathVariable Integer customerId) {
        return checkOrderRecordService.getCheckOrderRecordsByCustomerId(customerId);
    }

    @Operation(summary = "更新检查医嘱执行记录", description = "修改检查医嘱执行记录的信息（如执行结果、状态等）")
    @PutMapping("/update/{checkOrderRecordId}")
    public void updateCheckOrderRecord(
            @Parameter(description = "检查医嘱执行记录ID", required = true) @PathVariable Integer checkOrderRecordId,
            @Parameter(description = "更新后的执行记录信息", required = true) @RequestBody CheckOrderRecord checkOrderRecord) {
        checkOrderRecord.setCheckOrderRecordId(checkOrderRecordId);
        checkOrderRecordService.updateCheckOrderRecord(checkOrderRecord);
    }

    @Operation(summary = "删除检查医嘱执行记录", description = "移除指定的检查医嘱执行记录")
    @DeleteMapping("/delete/{checkOrderRecordId}")
    public void deleteCheckOrderRecord(
            @Parameter(description = "检查医嘱执行记录ID", required = true) @PathVariable Integer checkOrderRecordId) {
        checkOrderRecordService.deleteCheckOrderRecord(checkOrderRecordId);
    }

    @Operation(summary = "查询检查医嘱对应的执行记录", description = "根据检查医嘱ID获取其所有执行记录")
    @GetMapping("/checkOrder/{checkOrderId}")
    public List<CheckOrderRecord> getCheckOrderRecordByCheckOrder(
            @Parameter(description = "检查医嘱ID", required = true) @PathVariable Integer checkOrderId) {
        return checkOrderRecordService.getCheckOrderRecordByCheckOrder(checkOrderId);
    }
}